<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: listcategories.php 62 2013-09-21 11:59:12Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 62 $
* 	zuletzt geaendert von:	$Author: peter $
* 	Datum:					$Date: 2013-09-21 11:59:12 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require('includes/application_top.php');

?>
<html>
	<head>
		<title>Valid Categories/Products List</title>
		<style type="text/css">
		<!--
		h4 {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small; text-align: center}
		p {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small}
		th {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small}
		td {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small}
		-->
		</style>
	<head>
	<body>
		<table width="550" border="1" cellspacing="1" bordercolor="gray">
			<tr>
				<td colspan="4"><h4>Valid Categories List</h4></td>
			</tr>
<?php
   			$get_result = $db->db_query("SELECT restrict_to_categories FROM " . TABLE_COUPONS . " WHERE coupon_id='".$_GET['cid']."'");

echo '		<tr>
   				<th>Category ID</th>
   				<th>Category Name</th>
   			</tr>
   			<tr>';
   $cat_ids = explode(',', $get_result->fields['restrict_to_categories']);
   for ($i = 0; $i < count($cat_ids); $i++) {
     $row = $db->db_query("SELECT * FROM ".TABLE_CATEGORIES." c, ".TABLE_CATEGORIES_DESCRIPTION." cd WHERE c.categories_id = cd.categories_id and cd.language_id = '" . $_SESSION['languages_id'] . "' and c.categories_id='" . $cat_ids[$i] . "'");
     if ($row->_numOFRows) {
       echo '<td>'.$row->fields['categories_id'].'</td>\n';
       echo '<td>'.$row->fields['categories_name'].'</td>\n';
       echo '</tr>\n';
     } 
   }
echo '	</table>\n';
?>
<br>
<table width="550" border="0" cellspacing="1">
<tr>
<td align=middle><input type="button" value="Close Window" onClick="window.close()"></td>
</tr></table>
</body>
</html>